package com.nf.action;

import com.nf.entity.DataPackage;
import com.nf.service.ArticleService;
import com.nf.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DataPackageAction {
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ArticleService articleService;

    @ResponseBody
    @RequestMapping("/componentDidMount")
    public DataPackage componentDidMount(){
        DataPackage dp = new DataPackage();
        dp.setCategoryList( categoryService.getCategoryList() );
        dp.setArticleList( articleService.getArticleListByCategoryId(1) );
        return dp;
    }

}
